import router from './router'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import store from '@/store'
// import store from "@/store";

NProgress.configure({ showSpinner: false }) // NProgress Configuration

router.afterEach(() => {
  // finish progress bar
  NProgress.done()
})

const whiteList = ['/login', '/introduce', '/404']

router.beforeEach((to, from, next) => {
  if (store.getters.token || whiteList.includes(to.path)) {
    store.commit('navigation/setTabList', { path: to.path, title: to.meta.title })
    next()
  } else {
    next('/login')
  }
})
